<?php

session_start();
include("../includes/conn.php");
$dbconn->admin_logincheck();
$adminid=$_SESSION['adminid'];
if(!magic_quotes_runtime()) { 
$_GET = daddslashes($_GET); 
$_POST = daddslashes($_POST); 
$_COOKIE = daddslashes($_COOKIE); 
$_FILES = daddslashes($_FILES); 
} 
//添加
if($_GET['act']=='add'){
	//magic_quotes_runtime();
	$title=$_POST['title'];
	$desc=$_POST['desc'];
	$url=$_POST['url'];
	$content = htmlspecialchars($_POST['content1']);//exit;
//	echo $content;exit;
//	if (!empty($content)) {
//		if (!get_magic_quotes_gpc()) 
//		{
//		    $content = addslashes($content);
//		} 
//		else 
//		{
//		    $content = $content;
//		}
//	}
	
	$time = date('Y-m-d H:i:s',time());
//	echo 'insert into '.DBQIAN.'rules(title,desc,time,content,url) values(\''.$title.'\',\''.$desc.'\',\''.$time.'\',\''.$content.'\',\''.$url.'\')';exit;
	$dbconn->noretquery('INSERT INTO `'.DBQIAN.'rules` (`id`, `title`, `desc`, `content`, `time`, `url`) values(null,\''.$title.'\',\''.$desc.'\',\''.$content.'\',\''.$time.'\',\''.$url.'\')');
	$dbconn->showalert("保存成功","rules.php",1);
}
//转义字符
function h2str($str)
{
	$str = str_replace('<', '&lt;', $str);
	$str = str_replace('>', '&gt;',  $str);
//	$str = str_replace( " ", "&nbsp;", $str);
//	$str = str_replace('/n/r', "<br />",  $str);
//	$str = str_replace(chr(13),'<br />',$str);
//	$str = str_replace("'","&#039;",$str);
	return $str;
}
function text_dowith($str)
{
    //将文本区的数据格式化为Mysql能接受的Html数据格式（去除容易引起Mysql误解的敏感字符）。
    $str = ereg_replace(" ","&nbsp;", $str); //将空格转化为html格式
    $str = ereg_replace("'","&#039;",$str);//将单引号转化为html格式
    $str = ereg_replace('"','&quot;',$str);//将双引号转化为html格式
    $str = ereg_replace("<","&lt;",$str);//将'<'转化为html格式
    $str = ereg_replace('>','&gt;',$str);//将'>'转化为html格式
    $str = ereg_replace(chr(13),'<br />',$str);//将换行符转化为html格式，,根据Textarea的wrap属性确定是否有此行，如chr（13）和“/n/r”两种格式都有，则将其中一个替换为“”
    $str = ereg_replace('/n/r','<br />',$str);//将换行符转化为html格式,根据Textarea的wrap属性确定是否有此行，如chr（13）和“/n/r”两种格式都有，则将其中一个替换为“”
    return $str;
}
function text_display($str)
{
    //将Mysql中的html格式的数据进行格式处理（用于显示在文本区中显示）
    $str = ereg_replace("<br />",chr(13), $str);
    $str = str_replace("&nbsp;", " ", $str);  
    $str = ereg_replace("&#039;","'",$str);
    $str = ereg_replace('&quot;','"',$str);
    $str = ereg_replace("&lt;","<",$str);
    $str = ereg_replace('&gt;','>',$str);
    return $str;
}
function daddslashes($string, $force = 1) 
{ 
	if(is_array($string)) 
	{ 
		foreach($string as $key => $val) 
		{ 
			unset($string[$key]); 
			$string[addslashes($key)] = daddslashes($val, $force); 
		} 
	} 
	else 
	{ 
		$string = addslashes($string); 
	} 
	return $string; 
}
;echo '<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>欢迎登录后台管理系统</title>
<link href="css/base.css" rel="stylesheet" type="text/css" />
<link href="css/right.css" rel="stylesheet" type="text/css">
<link href="css/select.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="k/themes/default/default.css" />
<link rel="stylesheet" href="k/plugins/code/prettify.css" />
<script charset="utf-8" src="k/kindeditor.js"></script>
<script charset="utf-8" src="k/lang/zh_CN.js"></script>
<script charset="utf-8" src="k/plugins/code/prettify.js"></script>
<script src="js/jquery.js"></script>
<script src="js/select-ui.min.js"></script>
<script>
$(document).ready(function(){
   $(function(){
   		$(\'#time\').datetimepicker();
   });
});
</script>
</head>
<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="index.php">首页</a></li>
    <li><a href="rules.php">规则说明</a></li>
    <li>添加</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>规则说明添加</span></div>
  <form name="radd" method="post" action="?act=add">
  <ul class="forminfo">
    <li>
      <label>标题</label>
      <input name="title" type="text" value="" class="dfinput" />
      <i></i></li>
    <li>
      <label>描述</label>
      <input name="desc" type="text" value="" class="dfinput" />
    </li>
    <li style="width:98%;height:242px;">
    	<label>规则内容</label>
    	<textarea name="content1" style="width:680px;height:240px;visibility:hidden;"></textarea>
		<br />
    	<i></i>
    </li>
    <li>
      <label>跳转网址</label>
      <input name="url" type="text" value="" class="dfinput" />
      <i>网址以http开头</i></li>
    <li>
      <label>&nbsp;</label>
      <input name="button" type="submit" class="btn" value="确认保存"/>
    </li>
  </ul>
  </form>
</div>
<script>
	KindEditor.ready(function(K) {
		var editor1 = K.create(\'textarea[name="content1"]\', {
			cssPath : \'k/plugins/code/prettify.css\',
			uploadJson : \'k/php/upload_json.php\',
			fileManagerJson : \'k/php/file_manager_json.php\',
			allowFileManager : true,
			afterCreate : function() {
				var self = this;
				K.ctrl(document, 13, function() {
					self.sync();
					K(\'form[name=radd]\')[0].submit();
				});
				K.ctrl(self.edit.doc, 13, function() {
					self.sync();
					K(\'form[name=radd]\')[0].submit();
				});
			}
		});
		prettyPrint();
	});
</script>
</body>
</html>'
?>